﻿
Imports DAO
Imports DTO

Public Class DangNhapBUS

    Public loai As Integer

    Public Function DangNhap(ByVal dn As NhanVienDTO) As Integer

        Dim kt As Integer = 0
        Dim nv As New NhanVienBUS
        Dim dt As New DataTable
        dt = nv.LayNhanVien()
        For i = 0 To dt.Rows.Count
            Dim dr As DataRow = dt.Rows(i)
            If dr.Item(0).ToString.Trim = dn.laytenDN.Trim And dr.Item(1).ToString.Trim = dn.LayPass.Trim Then
                If dr.Item(6) = 1 Then
                    kt = 1  ' ' ' ' loại nguoi dung la nhan vien
                Else
                    kt = 2
                End If
                Dim kq As New XuLyDangNhapDAO
                kq.KiemTra(dn)
                Exit For
            End If
        Next
        Return kt
    End Function


    Public Function KiemTraDangNhap(ByVal nv As NhanVienDTO) As Boolean
        Dim nhan As New XuLyDangNhapDAO
        Dim dt As New DataTable

        dt = nhan.KiemTra(nv)

        If dt.Rows.Count > 0 Then
            loai = Integer.Parse(dt.Rows(0).ItemArray(5).ToString())
            Return True
        End If
        Return False
    End Function
End Class
